var databaseInterface = require('./../public/javascripts/SQLQueries.js');
var game = require('./game.js');

var callbackServerTests = {

    "Check for Duplicate User": function (req, res, index, returnFunction) {

        databaseInterface.checkDuplicateUser(req, res, 'test', function(response) {

            returnFunction(index, response);
            console.log(response);

        });
    }


};

var serverTests = {
    "Game Start": function () {
        var instance = new game.Game("test1", "test2");
        return (instance.player1 === "test1" && instance.player2 === "test2");
    },

    "Valid Place Ship": function () {
        var instance = new game.Game("test1", "test2");
        var returnVal = instance.placeShip("test1", 'Destroyer', "A1", "Down");
        console.log("Return Value" + returnVal.status);
        return returnVal.status == "success";
    },

    "Invalid Place Ship": function () {
        var instance = new game.Game("test1", "test2");
        var returnVal = instance.placeShip("test1", 'Destroyer', "A0", "Left");
        console.log("Return Value" + returnVal.status);
        return returnVal.status == "failure";
    }

};

exports.getTests = function () {

    return {tests: serverTests, callbackTests: callbackServerTests};

};

exports.addTest = function (testName, testFunction) {

    serverTests[testName] = testFunction;

};
